package com.blockmeta.bbs.baselibrary.widget;

import android.content.Context;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * @author AirThor
 * @date 2018/6/25.
 */

public class ToggleScrollRecyclerView extends RecyclerView {
    private boolean isCanScroll=true;
    public void setCanScroll(boolean canScroll) {
        isCanScroll = canScroll;
    }

    public ToggleScrollRecyclerView(Context context) {
        super(context);
    }

    public ToggleScrollRecyclerView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public ToggleScrollRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent arg0) {
        return isCanScroll && super.onInterceptTouchEvent(arg0);
    }

    @Override
    public boolean onTouchEvent(MotionEvent e) {
        return isCanScroll && super.onTouchEvent(e);
    }
}
